package Exercise;

import java.util.Comparator;

public class binarysearch {
    private static <T> int search(T[] a,int fromindex,int toindex,T key,Comparator<? super T> c)
    {
        int low=fromindex;
        int light=toindex-1;
        while(low<=light){
            int mid =(low+light)>>>1;
            T midval=a[mid];
            int cmp=c.compare(midval, key);
            if(cmp<0)
                low=mid+1;
            else if(cmp>0)
                light=mid+1;
            else 
                return mid;

        }
        return -(low+1);

    }
}
